/* ========================================================================= */
/* ------------------------------------------------------------------------- */
/*!
  \file			iprop.h
  \date			Oct 2012
  \author		TNick

  \brief		Contains the definition for IProp class


*//*


 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 Please read COPYING and README files in root folder
 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
*/
/* ------------------------------------------------------------------------- */
/* ========================================================================= */
#ifndef __IPROP_INC__
#define __IPROP_INC__
//
//
//
//
/*  INCLUDES    ------------------------------------------------------------ */

#include	<QString>

/*  INCLUDES    ============================================================ */
//
//
//
//
/*  CLASS    --------------------------------------------------------------- */

class	PropBase;


/**
*	@brief	Interface for objects that have properties
*
*	Each object that holds standard properties are required by IProp to report
*	a string of indices. The initialisation code creates an array of PropBase
*	classes that match that indices. The object must also provide two
*	functions (get and set) for each index that it reports in that string.
*/

class IProp				{

	//
	//
	//
	//
	/*  DEFINITIONS    ----------------------------------------------------- */

	/**
	*	@brief	the data type for one index (may be 8-bit or 16-bit, for example)
	*/
#	define		PropIndex			quint16

	/*  DEFINITIONS    ===================================================== */
	//
	//
	//
	//
	/*  DATA    ------------------------------------------------------------ */


private:



	/*  DATA    ============================================================ */
	//
	//
	//
	//
	/*  FUNCTIONS    ------------------------------------------------------- */

public:


	/**
	*	@brief	constructor;
	*/
	IProp					( void );


	/**
	*	@brief	destructor;
	*/
	virtual					~IProp				( void );


	/**
	*	@brief	presents all properties of this instance
	*
	*	Each property is printed on a single line.
	*	If \b b_with_val is true values for each property is also printed.
	*	If \b b_with_info is true a brief description joins the property.
	*
	*/
	QString					dumpProps			(
			bool					b_with_val = true,
			bool					b_with_info = true
			) const;


	/**
	*	@brief	gets the value of the given property as a string
	*/
	QString					propValueAsString	(
			PropIndex				idx,
			const PropBase *		prp_base = NULL
			) const;




	/* ******************************************************************* */
	/** @name 	Methods that are required from implementing classes        */
	/* ******************************************************************* */
	///@{


	/**
	*	@brief	get the string of properties
	*/
	virtual PropIndex *		properties			(
				int &				count
				) const = 0;




	///@}
	/* ******************************************************************* */



	/* ******************************************************************* */
	/** @name 	Methods for getting a property in native form              */
	/* ******************************************************************* */
	///@{


	/**
	*	@brief	get the value of a string property
	*/
	virtual QString			property			(
			PropIndex idx, const QString & def_val = QString() ) const
	{
		Q_UNUSED( idx );
		return def_val;
	}


	/**
	*	@brief	get the value of a boolean property
	*/
	virtual bool			property			( PropIndex idx, bool def_val = false ) const
	{
		Q_UNUSED( idx );
		return def_val;
	}


	/**
	*	@brief	get the value of an integer property
	*/
	virtual qint64			property			( PropIndex idx, qint64 def_val = 0 ) const
	{
		Q_UNUSED( idx );
		return def_val;
	}


	/**
	*	@brief	get the value of a real property
	*/
	virtual qreal			property			( PropIndex idx, qreal def_val = 0 ) const
	{
		Q_UNUSED( idx );
		return def_val;
	}


	/**
	*	@brief	get the value of a string of real properties
	*/
	virtual bool			property			( PropIndex idx, int count, qreal * out_val, qreal * def_val = NULL ) const
	{
		Q_UNUSED( idx );
		if ( ( def_val != NULL ) && ( out_val != NULL ) )
		{
			memccpy( out_val, def_val, count, sizeof( qreal ) );
			return true;
		}
		return false;
	}


	///@}
	/* ******************************************************************* */


	/* ******************************************************************* */
	/** @name 	Methods for setting a property in native form              */
	/* ******************************************************************* */
	///@{


	/**
	*	@brief	get the value of a string property
	*/
	virtual bool			setProperty			( PropIndex idx, QString & inp_val )
	{
		Q_UNUSED( idx );
		Q_UNUSED( inp_val );
		return false;
	}


	/**
	*	@brief	get the value of a boolean property
	*/
	virtual bool			setProperty			( PropIndex idx, bool inp_val )
	{
		Q_UNUSED( idx );
		Q_UNUSED( inp_val );
		return false;
	}


	/**
	*	@brief	get the value of an integer property
	*/
	virtual bool			setProperty			( PropIndex idx, qint64 inp_val )
	{
		Q_UNUSED( idx );
		Q_UNUSED( inp_val );
		return false;
	}


	/**
	*	@brief	get the value of a real property
	*/
	virtual bool			setProperty			( PropIndex idx, qreal inp_val )
	{
		Q_UNUSED( idx );
		Q_UNUSED( inp_val );
		return false;
	}


	/**
	*	@brief	get the value of a string of real properties
	*/
	virtual bool			setProperty			( PropIndex idx, int count, qreal * inp_val )
	{
		Q_UNUSED( idx );
		Q_UNUSED( count );
		Q_UNUSED( inp_val );
		return false;
	}

	///@}
	/* ******************************************************************* */



	/*  FUNCTIONS    ======================================================= */
	//
	//
	//
	//

};	/*	class IProp	*/

/*  CLASS    =============================================================== */
//
//
//
//
#endif // __IPROP_INC__
/* ------------------------------------------------------------------------- */
/* ========================================================================= */
